<?php

class ActionEditTest extends Action {
	public function IsPermitted(){ return true; }


	private $test;
	public function __construct(Test $test){ $this->test = $test; }
	public function GetUrlArgs(){ return array('id'=>$this->test); }
	public static function Make($class){ return new $class(Test::Retrieve(Http::$GET['id']->AsID())); }

	public function Render(){

		$ui = $this->test->GetUIObject();

		if ($this->IsPostback()){
			$ui->Read(Http::$POST);
			$this->test->Save();
			Oxygen::Redirect(new ActionHome());
		}


		echo $this->GetForm();
		echo '<label>'.$ui->some_string->GetLabel().'</label>';
		echo '<br/>'.TextboxControl::Make($ui->some_string);

		echo '<br/><br/>';
		echo '<label>'.$ui->some_integer->GetLabel().'</label>';
		echo '<br/>'.TextboxControl::Make($ui->some_integer);

		echo '<br/><br/>';
		echo ButtonControl::Make()->WithValue(Lemma::Retrieve('Save'))->WithIsSubmit(true);
		echo $this->EndForm();



	}
}
?>
